<link href="<?php echo base_url('theme/css/frontend/account-manager.css'); ?>" rel="stylesheet">
<link rel="stylesheet" href="<?php echo base_url('theme/css/frontend/jquery.Jcrop.min.css'); ?>" type="text/css" />
<div class="wrapper account-wrapper acc-info-wrapper">
  <?php echo validation_errors('<div class="alert alert-error">','</div>'); ?>

  <h3>Thay đổi thông tin tài khoản</h3>
  <hr class=hr /> 
  
  <div class="account-container" style="background-color: #CDCDCD">
    <form method="post" id="upload_avatar" class="form-horizontal" action=<?php echo base_url('user/uploadFileWithAjax'); ?> enctype=multipart/form-data > 
      <h5>Ảnh đại diện</h5>
      <hr class="hr" />
      <div class="control-group">
        <label for="avatar" class="control-label">Chọn ảnh</label>
        <div class="controls">
          <input type="hidden" id="MAX_FILE_SIZE" name="MAX_FILE_SIZE" value="600000" />
          <input type="file" id="avatar" name="avatar" />
       	</div>
      </div>
      <div class="submitbutton">
        <button type="submit">Upload Files</button>
      </div>
    </form>
    <div id="avatar_append"></div>
    <form class="form-horizontal" action="<?php echo base_url('user/addAvatar'); ?>" method="post">
       <?php /*
      <div class="control-group">
  	    <label for="sex" class="control-label">Chọn giới tính</label>
  	    <div class="controls">
  	  	  <label class="radio inline">
  	  	    <input type="radio" value="1" name="avatar">
  	  	    <img style="width:50px; height:55px;" class="img-polaroid" src="<?php echo base_url('theme/images/frontend/user-default-avatar.jpg'); ?>">
      	  </label>
      	  <label class="radio inline">
  	  	    <input type="radio" value="2" name="avatar">
  	  	    <img style="width:50px; height:55px;" class="img-polaroid" src="<?php echo base_url('theme/images/frontend/user-default-avatar.jpg'); ?>">
      	  </label>
      	  <label class="radio inline">
  	  	    <input type="radio" value="3" name="avatar">
  	  	    <img style="width:50px; height:55px;" class="img-polaroid" src="<?php echo base_url('theme/images/frontend/user-default-avatar.jpg'); ?>">
      	  </label>
      	  <label class="radio inline">
  	  	    <input type="radio" value="4" name="avatar">
  	  	    <img style="width:50px; height:55px;" class="img-polaroid" src="<?php echo base_url('theme/images/frontend/user-default-avatar.jpg'); ?>">
      	  </label>
      	  <label class="radio inline">
  	  	    <input type="radio" value="5" name="avatar">
  	  	    <img style="width:50px; height:55px;" class="img-polaroid" src="<?php echo base_url('theme/images/frontend/user-default-avatar.jpg'); ?>">
      	  </label>
  	    </div>
  	    <div class="controls">
  	  	  <label class="radio inline">
  	  	    <input type="radio" value="6" name="avatar">
  	  	    <img style="width:50px; height:55px;" class="img-polaroid" src="<?php echo base_url('theme/images/frontend/user-default-avatar.jpg'); ?>">
      	  </label>
      	  <label class="radio inline">
  	  	    <input type="radio" value="7" name="avatar">
  	  	    <img style="width:50px; height:55px;" class="img-polaroid" src="<?php echo base_url('theme/images/frontend/user-default-avatar.jpg'); ?>">
      	  </label>
      	  <label class="radio inline">
  	  	    <input type="radio" value="8" name="avatar">
  	  	    <img style="width:50px; height:55px;" class="img-polaroid" src="<?php echo base_url('theme/images/frontend/user-default-avatar.jpg'); ?>">
      	  </label>
      	  <label class="radio inline">
  	  	    <input type="radio" value="9" name="avatar">
  	  	    <img style="width:50px; height:55px;" class="img-polaroid" src="<?php echo base_url('theme/images/frontend/user-default-avatar.jpg'); ?>">
      	  </label>
      	  <label class="radio inline">
  	  	    <input type="radio" value="10" name="avatar">
  	  	    <img style="width:50px; height:55px;" class="img-polaroid" src="<?php echo base_url('theme/images/frontend/user-default-avatar.jpg'); ?>">
      	  </label>
  	    </div>  
  	  </div>
  	  */ ?>
      <div class="control-group">
        <div class=controls>
          <input type="hidden" id="dataRecruitmentCropJson" name="dataRecruitmentCropJson" />
          <button class="btn btn-primary" type=submit name=avatar-submit value="Lưu thay đổi">Lưu thay đổi</button>
          <button class="btn" type="button">Hủy bỏ</button>
        </div>
      </div>
    </form>
  </div>
  
  <form method="post" id="form-user" class="form-horizontal account-container" action=<?php echo base_url('user/changingAccountInformation'); ?>>     
    <?php 
      $fieldsArray = array(
    	'real_name' => 'Họ và tên',
    	'email' => 'Email',
    	'password' => 'Mật khẩu',
    	'tel' => 'Số điện thoại',
    	'address' => 'Địa chỉ',
    	'sex' => 'Giới tính',
    	'birthday' => 'Sinh nhật'
      ); 
    ?>
    <?php foreach ($fieldsArray as $field => $label): ?>
    <?php if ($field == 'password') {
      $content = '******';
    } elseif ($field == 'sex') {
      if ($user[$field] == 1) {
        $content = 'Nam';
      } elseif ($user[$field] == 2) {
        $content = 'Nữ';
      }
    } elseif ($field == 'birthday') {
      if ($num = strtotime($user[$field])) {
        $content = date('d/m/Y', $num);
      } else {
        $content = '--';
      }
    } else {
      $content = $user[$field];
    }
    ?>
    <div class=form-header><span class="title"><?php echo $label; ?>:</span> <?php echo $content; ?> <span class="edit" id="<?php echo $field; ?>-edit">Chỉnh sửa</span></div>
    <hr class="hr" />
    <div class="form-wrapper" id="<?php echo $field; ?>-wrapper">
      <div class="control-group">
        <label class="control-label"><?php echo $label; ?> hiện tại</label>
        <div class="controls"><?php echo $content; ?></div>
      </div>
      <div class="control-group">
        <label for="real_name" class="control-label"><?php echo $label; ?> thay thế</label>
        <div class="controls">
          <?php if ($field == 'password'): ?>
			<input type=password name=password id=password>
          <?php elseif ($field == 'sex'): ?>
           	<label class="radio inline">
    	  	  <input type=radio name=sex value="1" checked/> Nam
        	</label>
        	<label class="radio inline">
    	  	  <input type=radio name=sex value="2"/> Nữ
        	</label>
          <?php elseif ($field == 'birthday'): ?>
            <select name=day id=day> 
        	  <option value=0>Ngày</option>
              <?php for ($i = 1; $i <= 31; $i++): ?>
                <option value="<?php echo $i ?>"><?php echo $i ?></option>        
              <?php endfor; ?>        
        	</select>
        	<select name=month id=month>
              <option value=0>Tháng</option>
              <option value=1>1</option>
              <option value=2>2</option>
              <option value=3>3</option>
              <option value=4>4</option>
              <option value=5>5</option>
              <option value=6>6</option>
              <option value=7>7</option>
              <option value=8>8</option>
              <option value=9>9</option>
              <option value=10>10</option>
              <option value=11>11</option>
              <option value=12>12</option>        
        	</select>
            <select name=year id=year>
              <option value=0>Năm</option>
              <?php for ($i = 2003; $i > 1950; $i--): ?>
                <option value="<?php echo $i ?>"><?php echo $i ?></option>        
              <?php endfor; ?>  
            </select>		       
          <?php else: ?>
            <input type=text name=<?php echo $field; ?> id=<?php echo $field; ?> class="input-xlarge">
          <?php endif; ?>
        </div>
      </div>
      <div class="control-group">
        <div class=controls>
          <button class="btn btn-primary" type=submit name="<?php echo $field; ?>-submit" value="Lưu thay đổi">Lưu thay đổi</button>
          <button class="btn" type="button" id="<?php echo $field; ?>-cancel">Hủy bỏ</button>
        </div>
      </div>
    </div>
    <script type="text/javascript">
    $(document).ready(function(){
      $('#<?php echo $field; ?>-edit, #<?php echo $field; ?>-cancel').click(function() {
        $('#<?php echo $field; ?>-wrapper').slideToggle('slow', function() {
          // Animation complete.
        });
      }); 	
    });
    </script>
    <?php endforeach; ?>
  </form>
</div>
<script src="<?php echo base_url('theme/js/frontend/jquery.Jcrop.min.js'); ?>"></script>
<script src="<?php echo base_url('theme/js/frontend/jquery.json-2.4.min.js'); ?>"></script>
<script src="<?php echo base_url('theme/js/frontend/avatar.crop.js'); ?>"></script>